home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Moscow ML 1.31 / source code / mosml / src / mosmllib / Char.sig < prev    next >
Encoding:
Text File  |  1996-07-03  |  3.8 KB  |  107 lines  |  [TEXT/R*ch]

  1. (* Char -- SML Standard Library *)
  2.  
  3. type char = char
  4.  
  5. exception Chr
  6.  
  7. val minChar : char
  8. val maxChar : char
  9. val maxOrd  : int       
  10.  
  11. val chr  : int  -> char         (* may raise Chr *)
  12. val ord  : char -> int
  13. val succ : char -> char         (* may raise Chr *)
  14. val pred : char -> char         (* may raise Chr *)
  15.  
  16. val isLower    : char -> bool   (* contains "abcdefghijklmnopqrstuvwxyz"  *)
  17. val isUpper    : char -> bool   (* contains "ABCDEFGHIJKLMNOPQRSTUVWXYZ"  *)
  18. val isDigit    : char -> bool   (* contains "0123456789"                  *)
  19. val isAlpha    : char -> bool   (* isUpper orelse isLower                 *)
  20. val isHexDigit : char -> bool   (* isDigit orelse contains "abcdefABCDEF" *)
  21. val isAlphaNum : char -> bool   (* isAlpha orelse isDigit                 *)
  22. val isPrint    : char -> bool   (* any printable character (incl. #" ")   *)
  23. val isSpace    : char -> bool   (* contains " \t\r\n\v\f"                 *)
  24. val isPunct    : char -> bool   (* printable, not space or alphanumeric   *) 
  25. val isGraph    : char -> bool   (* (not isSpace) andalso isPrint          *)
  26. val isAscii    : char -> bool   (* ord c < 128                            *)
  27. val isCntrl    : char -> bool   (* control character                      *)
  28.  
  29. val toLower    : char -> char
  30. val toUpper    : char -> char
  31.  
  32. val contains    : string -> char -> bool
  33. val notContains : string -> char -> bool
  34.  
  35. val <  : char * char -> bool
  36. val <= : char * char -> bool
  37. val >  : char * char -> bool
  38. val >= : char * char -> bool
  39. val compare : char * char -> ordering
  40.  
  41. (* [char] is the type of characters.  
  42.  
  43.    [minChar] is the least character in the ordering <.
  44.  
  45.    [maxChar] is the greatest character in the ordering <.
  46.  
  47.    [maxOrd] is the greatest character code; equals ord(maxChar).
  48.  
  49.    [chr i] returns the character whose code is i.  Raises Chr if
  50.    i<0 or i>maxOrd.
  51.  
  52.    [ord c] returns the code of character c.
  53.  
  54.    [succ c] returns the character immediately following c, or raises
  55.    Chr if c = maxChar.
  56.  
  57.    [pred c] returns the character immediately preceding c, or raises
  58.    Chr if c = minChar.
  59.  
  60.    [isLower c] returns true if c is a lowercase letter (a to z).
  61.  
  62.    [isUpper c] returns true if c is a uppercase letter (A to Z).
  63.  
  64.    [isDigit c] returns true if c is a decimal digit (0 to 9).
  65.  
  66.    [isAlpha c] returns true if c is a letter (lowercase or uppercase).
  67.  
  68.    [isHexDigit c] returns true if c is a hexadecimal digit (0 to 9 or 
  69.    a to f or A to F).
  70.  
  71.    [isAlphaNum c] returns true if c is alphanumeric (a letter or a
  72.    decimal digit).
  73.  
  74.    [isPrint c] returns true if c is a printable character (space or visible)
  75.  
  76.    [isSpace c] returns true if c is a whitespace character (blank, newline,
  77.    tab, vertical tab, new page).
  78.  
  79.    [isGraph c] returns true if c is a graphical character, that is,
  80.    it is printable and not a whitespace character.
  81.  
  82.    [isAscii c] returns true if c is a (seven-bit) ASCII character.
  83.  
  84.    [toLower c] returns the lowercase letter corresponding to c,
  85.    if c is a letter; otherwise returns c.
  86.  
  87.    [toUpper c] returns the uppercase letter corresponding to c,
  88.    if c is a letter; otherwise returns c.
  89.  
  90.    [contains s c] returns true if character c occurs in the string s;
  91.    false otherwise.  The function, when applied to s, builds a table
  92.    and returns a function which uses table lookup to decide whether a
  93.    given character is in the string or not.  Hence it is relatively
  94.    expensive to compute  val p = contains s  but very fast to compute 
  95.    p(c) for any given character.
  96.  
  97.    [notContains s c] returns true if character c does not occur in the
  98.    string s; false otherwise.  Works by construction of a lookup table
  99.    in the same way as the above function.
  100.  
  101.    [c1 < c2] returns true if ord(c1) < ord(c2), and similarly for <=,
  102.    >, >=.  
  103.  
  104.    [compare(c1, c2)] returns LESS, EQUAL, or GREATER, according as c1 is
  105.    precedes, equals, or follows c2 in the ordering Char.< .
  106. *)
  107.